﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="Phoenix.Service.Model" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Index
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<form id="form1" runat="server">
<div class="path">
        <a href="/productcategory/index"><strong>新闻管理</strong></a>
    </div>
    <div class="pd10">
        <div class="mb10 aL">
            <a href="/News/Edit" title="添加新闻" class="a-btn1" >添加新闻</a>
            <a href="/Views/Category/Index.aspx?pid=1" title="新闻分类" class="a-btn1" >新闻分类</a>
             <span style="float:right;">按分类查看
              <select id="sltCategoryID" name="sltCategoryID">
                    <option value="0">所有</option>
                        <%  IList<NewsCatalogModel> CatalogList = ViewData["CatalogList"] as List<NewsCatalogModel>; %> 
                       <% foreach (var item in CatalogList) %>
                       <% {%>
                       <option value="<%=item.CatalogID %>"><%=item.CatalogName%></option>
                       <%} %>
                    </select>
            </span>
        </div>
          <span id="Grid">
<table class="tb-list hover">
    <tr>
        <th>
            新闻标题
        </th>
        <th>
            新闻分类
        </th>
        <th>
            发布时间
        </th>
        <th width="20%">
            操作
        </th>
    </tr>
    <%  IList<NewsModel> NewsList = ViewData["NewsList"] as List<NewsModel>; %>
    <%foreach (var item in NewsList) %> 
    <%{ %>
     <tr>
        <td style="width:30%">
           <%=item.Title %>
        </td>
         <td style="width:20%">
           <%=item.CatalogName %>
        </td>         
        <td style="width:30%">
           <%=item.CreateTime %>
        </td>
        <td style="width:20%">
            <a href="Edit?nid=<%=item.NewsID %>">编辑</a> <a href="javascript:;" onclick="DeleteNews('<%=item.NewsID %>')">删除</a>
        </td>
    </tr>
    <%} %>
</table>
        </span>
            <!-- 分页插件  -->
        <div id="pager" class="aR mt10">
        </div>

    </div>
    </form>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeadStyles" runat="server">  
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="HeadScripts" runat="server">
        <script type="text/javascript" src="/Scripts/m-lhgdialog/m-lhgdialog.js"></script>    
	<script type="text/javascript" src="/Scripts/library/m-pagination.js"></script>    

</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="BodyScripts" runat="server">
    <script type="text/javascript">

        // 删除类目
        function DeleteNews(newsID) {
            if (confirm("确认删除吗?") == false) {
                return;
            }

            $.ajax({
                url: "/News/Delete",
                data: { "newsId": newsID },
                type: "POST",
                success: function (data, textStatus) {
                    if (data.status === "warning" || data.status === "error") {
                        alert(data.msg);
                        return false;
                    }
                    // 刷新列表
                    refresh();
                },
                error: function (XmlHttpRequest, textStatus, errorThrown) {
                    alert(errorThrown);
                }
            });
        };

        // 显示编辑
        function showEdit(nid, cid) {
            OpenPop('/News/edit?nid=' + nid, "编辑商品类目", 500, 250);
        };

        //打开弹窗
        function OpenPop(url, titleName, width, height) {
            width = width || 800;
            height = height || 500;
            window.top.winObj = window;
            window.top.oDG = new $.dialog({ id: 'esDialog', title: titleName, page: url, width: width, height: height, btnBar: false, lockScroll: true });
            window.top.oDG.ShowDialog();
        }
        
</script> 
</asp:Content>
